<?php
namespace admin\controller
{

 class   Index extends \Api\Controller
 {
    public  function    indexAction(array $params=array())
    {        
       // $this->view->display('help');       
       \Api\Redirect::ToAction('help');
    }
    
    /**
     * Company data editing
     */
    public function     firmdataAction(array $params=array())
    {        
        $this->layout->SetScript('/api.js/FieldTest.js','js');
        $this->layout->SetScript('/local/firm-data.js','js');        
        $this->layout->SetTitle('Edycja danych firmy');
        $this->view->display();
    }
    
    /**
     * Update films from youtube account to db
     */
    public function     filmAction(array $params=array())
    {   
        $this->layout->SetTitle('Baza filmów');
        $this->layout->SetScript('/local/film.js','js');
        $this->layout->SetScript('/api.js/swfobject.js','js');
        $this->layout->SetScript('/local/film.css','css');
        
        $film = new \Admin\Model\Film($this->config);
        $this->view->movies=$film->get();
        
        $this->view->display();
    }
    
    /**
     * Subpage editing
     */
    public  function    subpagesAction(array $params=array())
    {        
        $sub = new \Admin\Model\Subpages($this->config);
        $this->layout->SetScript('/local/Subpages.js','js');
        $this->layout->SetTitle('Zarządzanie podstronami');
        $page = '';
        
        if(count($params) == 2 && $params[0]=='edit')
        {
            $page = 'subpages.edit';
            $this->view->action = $params[0];
            $this->view->content = $sub->GetSubpage($params[1]);
            $this->view->templates = $sub->TemplateList('site','index');
            $this->view->backgrounds = $sub->BackgroundList();
            $this->view->effects = $sub->ReturnEffect();
            
        }else if(count($params) == 1 && $params[0] == 'add')
        {
            $page = 'subpages.edit';
            $this->view->action = $params[0];            
            $this->view->content = array();
            $this->view->templates = $sub->TemplateList('site','index');
            $this->view->backgrounds = $sub->BackgroundList();
            $this->view->effects = $sub->ReturnEffect();
        }
        else
        {
            $this->view->content = $sub->GetSubpagesList();
        }                
        $this->layout->SetScript('/api.js/UI.js','js');
        $this->view->display($page);       
    }
    
    /**
     *  Login form
     */
    public function     loginAction(array $params = array())
    {
        $this->view->display('login-form','_shared');
        $this->layout->SetLayout('login-layout.tpl');
        $this->layout->SetTitle('Zaloguj');
    }
    
    /**
     * Help action
     */
    public function helpAction(array $params = array())
    {
        $this->layout->SetTitle('Pomoc');
        $this->layout->SetScript('/api.js/UI.js','js');
        $this->view->display();
    }
    /**
     * Error
     */
    public function errorAction(array $params = array())
    {
    }
 };

}
?>